import os
import logging

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

LOG = logging.getLogger(__name__)

adb_db_path = os.path.abspath(os.path.join(os.getenv('OutputDir', './'), 'adb-api.db'))
LOG.info("db path is {}".format(adb_db_path))
SQLALCHEMY_DATABASE_URL = "sqlite:///{}".format(adb_db_path)
# SQLALCHEMY_DATABASE_URL = "postgresql://user:password@postgresserver/db"

engine = create_engine(
    SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base()
